package com.dyh.quickdemozwei.futureopreate;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

public class TestDrain {

    /*
    add throw new IllegalStateException("Queue full")
    offer false
    put 一直等
    offer 带时间
    */
//    public static void main(String[] args) {
//        BlockingQueue<String> queue = new LinkedBlockingQueue<>(2);
////        queue.offer("1");
////        queue.offer("2");
////        queue.offer("3");
////        queue.offer("4");
//
//        List<String> list = new ArrayList<>(2);
//
//        queue.drainTo(list,2);
//
//        System.out.println(JSON.toJSONString(list));
//
//        queue.drainTo(list,2);
//        System.out.println(JSON.toJSONString(list));
//
//    }


    public static void main(String[] args) {
        BlockingQueue<String> queue = new LinkedBlockingQueue<>(2);
        System.out.println(queue.offer("1"));
        System.out.println(queue.offer("2"));
        System.out.println(queue.offer("3"));

//        queue.take();

    }
}
